/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var doc_actual = 1;



 var url = location.href;

   var map;
    var geocoder;
    var address;
var sitio;
function agregarUnElemento(tipo)
{
    
    
        if(tipo=="doc")
        {
            //alert("docum: "+tipo);
            var input_doc = document.createElement('input');
                input_doc.setAttribute('type','file');
                doc_actual = doc_actual + 1;
                input_doc.setAttribute('id','doc_'+doc_actual);
                input_doc.setAttribute('name','doc_'+doc_actual);

            document.getElementById('doc').appendChild(input_doc);
        }
        
}
function mostrarMapaGoogle()
{
    var chk_reunion = document.getElementById('chk_reunion');
    var input_reunion_lat = document.getElementById('txtLatitud');
    var input_reunion_long = document.getElementById('txtLongitud');

    if(chk_reunion.checked)
    {
        input_reunion_lat.value="";
        input_reunion_long.value="";
        input_reunion_lat.style.visibility="visible";
        input_reunion_long.style.visibility="visible";
        tb_show('', 'mapa_google_espol.jsp?KeepThis=true&TB_iframe=true&height=500&width=760&modal=true', false);

        //tb_show('', 'mapa_google_espol.jsp?KeepThis=true& input=' + input_reunion  +'&TB_iframe=true&height=540&width=760&modal=true', false);

    }
    else
    {
        input_reunion_lat.style.visibility="hidden";
        input_reunion_long.style.visibility="hidden";
    }


}


/*function initialize() {
   var lat_long = new google.maps.LatLng(-2.146574,-79.965105);//csi
   var myOptions = {
      zoom: 17,
      center: lat_long,
      mapTypeId: google.maps.MapTypeId.SATELLITE
    }
   var map = new google.maps.Map(document.getElementById("c_google_map"), myOptions);

  }*/



    function initialize() {
      map = new GMap2(document.getElementById("c_google_map"));
      map.setCenter(new GLatLng(-2.146574,-79.965105), 13);
      map.setUIToDefault();
      GEvent.addListener(map, "click", getAddress);
      geocoder = new GClientGeocoder();
    }

    function getAddress(overlay, latlng) {
      if (latlng != null) {
        address = latlng;
        geocoder.getLocations(latlng, showAddress);
      }
    }

    function showAddress(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        //alert("Status Code:" + response.Status.code);
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        marker = new GMarker(point);
        map.addOverlay(marker);

        marker.openInfoWindowHtml(

        '<b>Latitud:</b>' + place.Point.coordinates[1]  + '<br>' +
        '<b>Longitud:</b>' + place.Point.coordinates[0] + '<br>' +
        '<b>Lugar:</b>' + place.address + '<br>' +
        '<b>País:</b> ' + place.AddressDetails.Country.CountryName + '<br>' +
        '<a href="javascript:self.parent.setearLatitudLongitud(' + place.Point.coordinates[1] + ','+ place.Point.coordinates[0] +'); self.parent.tb_remove();">Seleccionar</a>');
     // alert(place.address);
  }
    }

function setearLatitudLongitud(latitud, longitud)
{
   var input_latitud = document.getElementById('txtLatitud');
   var input_longitud = document.getElementById('txtLongitud');


       
       input_latitud.value = latitud;
        input_longitud.value = longitud;
       
        input_latitud.disabled = true;
        input_longitud.disabled = true;
      

}

function setearTipoReunion()
{
   var input_latitud  = document.getElementById('txtLatitud');
   var input_longitud = document.getElementById('txtLongitud');
   
    var chk_reunion = document.getElementById('chk_reunion');
        //alert(input_latitud+" "+input_longitud );
        input_latitud .value = "";
        input_longitud.value = "";
  
        input_latitud .disabled = false;
        input_longitud.disabled = false;
        input_latitud .style.visibility="hidden";
        input_longitud.style.visibility="hidden";
        chk_reunion.checked =  false;
}


